package android07.newtop.presenter;

import android.support.v4.app.FragmentManager;
import android.util.Log;

import com.jude.beam.expansion.data.BeamDataActivityPresenter;

import android07.newtop.R;
import android07.newtop.activity.MainActivity;
import android07.newtop.adapter.MyPagerAdapter;
import android07.newtop.model.bean.MainBean;


/**
 * 主页
 * Created by hy on 2016/7/7.
 */
public class MainActivityPresenter extends BeamDataActivityPresenter<MainActivity, MainBean> {

    MyPagerAdapter myPagerAdapter;
    FragmentManager supportFragmentManager;

    private static final String TAG = MainActivityPresenter.class
            .getSimpleName();

    /**
     * activity 刚起床， 睁开眼的那一刻 执行
     *
     * @param view
     */
    @Override
    protected void onCreateView(MainActivity view) {
        super.onCreateView(view);
        //睁开眼，要干啥 ，要喝奶
        Log.d(TAG, "onCreateView: ");
///getDataSubscriber().onNext( 给Activity 填充数据的方法


        view.getTabLayout().setSelectedTabIndicatorColor(view.getResources().getColor(R.color.white));
        supportFragmentManager = getView().getSupportFragmentManager();
        replaceFragment(0);


    }

    public void replaceFragment(int position){
        if(myPagerAdapter==null){
            myPagerAdapter = new MyPagerAdapter(getView(),supportFragmentManager);
        }
        getView().getViewPager().setAdapter(myPagerAdapter);
        getView().getTabLayout().setupWithViewPager(getView().getViewPager());

    }

}
